//#include "ServerOSCThread.h"
#include "OSCthulhuServer.h"

ServerOSCThread::ServerOSCThread(OSCthulhuServer* server)
{
    this->server = server;
    this->receiveSocket = new UdpReceiveSocket(
            IpEndpointName( IpEndpointName::ANY_ADDRESS, server->getPort())
             //&listener
    );
    this->start();
}

void ServerOSCThread::run() {
    ServerPacketListener listener(server);
    mux.AttachSocketListener(this->receiveSocket,&listener);
    qDebug() << "press ctrl-c to end";
    mux.RunUntilSigInt();
    exec();
}

void ServerOSCThread::send(IpEndpointName ipEndpointName, osc::OutboundPacketStream p) {
    this->receiveSocket->SendTo(
            ipEndpointName,
            p.Data(),p.Size()
        );
}
